class GenericHttpBackup < Backup
  attr_meta :url, :username, :password, :authentication
    
  def output_path
    @output_path ||= "#{id}-generic-#{service}=#{file}"
  end
  
  def run
    if username && password
      xml = get url, :http_basic_authentication => [username, password]
    else
      xml = get url
    end
    
    write output_path, xml
  end

  def service
    url.scan(/[^\.\/]+\.[^\.\/]+$/)[0].downcase
  end
  
  def file
    url.gsub(/[^\.\/]+\/\/[^\.]+\./, '').gsub(/.+\//, '')
  end
    
end